import { agreementStatusEnum } from '../constant'
import { isAdmin, isPurchaser, isSupplier } from './use-role'

console.log(isAdmin, isPurchaser, isSupplier)

export const operateType = {
    initialA: {
        label: '发起',
        value: 'initialA',
    },
    edit: {
        label: '编辑',
        value: 'edit',
    },
    delete: {
        label: '删除',
        value: 'delete',
    },
    sign: {
        label: '签约',
        value: 'sign',
    },
    view: {
        label: '查看',
        value: 'view',
    },
    disabled: {
        label: '停用',
        value: 'disabled',
    },
}
// 映射操作
export const operateList = computed(() => {
    const operate = {}
    if (isPurchaser.value) {
        operate[agreementStatusEnum.initialA.value] = [operateType.initialA] // 待甲方发起状态的操作：发起
        operate[agreementStatusEnum.draft.value] = [operateType.edit, operateType.delete] // 草稿状态的操作：编辑、删除
        operate[agreementStatusEnum.pendingPartyB.value] = [operateType.view] // 待乙方签约状态的操作：查看
        operate[agreementStatusEnum.pendingPartyA.value] = [operateType.sign] // 待甲方签约状态的操作：签约
        operate[agreementStatusEnum.effective.value] = [operateType.view, operateType.disabled] // 已生效状态的操作：查看、停用
        operate[agreementStatusEnum.rejectedByPartyB.value] = [operateType.view] // 乙方驳回状态的操作：查看
        operate[agreementStatusEnum.rejectedByPartyA.value] = [operateType.view] // 甲方驳回状态的操作：查看
        operate[agreementStatusEnum.disabled.value] = [operateType.view] // 已停用状态的操作：查看
        operate[agreementStatusEnum.outService.value] = [operateType.view] // 已过期状态的操作：查看
    }
    if (isSupplier.value) {
        operate[agreementStatusEnum.initialA.value] = [operateType.view] // 待甲方发起状态的操作：发起
        operate[agreementStatusEnum.draft.value] = [operateType.view] // 草稿状态的操作：编辑、删除
        operate[agreementStatusEnum.pendingPartyB.value] = [operateType.sign] // 待乙方签约状态的操作：查看
        operate[agreementStatusEnum.pendingPartyA.value] = [operateType.view] // 待甲方签约状态的操作：签约
        operate[agreementStatusEnum.effective.value] = [operateType.view] // 已生效状态的操作：查看
        operate[agreementStatusEnum.rejectedByPartyB.value] = [operateType.view] // 乙方驳回状态的操作：查看
        operate[agreementStatusEnum.rejectedByPartyA.value] = [operateType.view] // 甲方驳回状态的操作：查看
        operate[agreementStatusEnum.disabled.value] = [operateType.view] // 已停用状态的操作：查看
        operate[agreementStatusEnum.outService.value] = [operateType.view] // 已过期状态的操作：查看
    }
    if (isAdmin.value) {
        operate[agreementStatusEnum.initialA.value] = [operateType.view] // 待甲方发起状态的操作：发起
        operate[agreementStatusEnum.draft.value] = [operateType.view] // 草稿状态的操作：编辑、删除
        operate[agreementStatusEnum.pendingPartyB.value] = [operateType.view] // 待乙方签约状态的操作：查看
        operate[agreementStatusEnum.pendingPartyA.value] = [operateType.view] // 待甲方签约状态的操作：签约
        operate[agreementStatusEnum.effective.value] = [operateType.view] // 已生效状态的操作：查看
        operate[agreementStatusEnum.rejectedByPartyB.value] = [operateType.view] // 乙方驳回状态的操作：查看
        operate[agreementStatusEnum.rejectedByPartyA.value] = [operateType.view] // 甲方驳回状态的操作：查看
        operate[agreementStatusEnum.disabled.value] = [operateType.view] // 已停用状态的操作：查看
        operate[agreementStatusEnum.outService.value] = [operateType.view] // 已过期状态的操作：查看
    }

    return operate
})
